﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using FarseerPhysics.Common;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using FarseerPhysics.Collision;
using FarseerPhysics.Collision.Shapes;
using FarseerPhysics.Controllers;
using FarseerPhysics.SamplesFramework;

namespace game
{
    /// <summary>
    /// Klasa przechwuje i ogarnia fizykę gracza. 
    /// </summary>
    class CPlayerPhysics
    {
        public Vector2 Position 
        {
            get
            {
                return _body.Position;
            }
        }

        public float Rotation
        {
            get
            {
                return _body.Rotation;
            }
        }
        
        public CPlayerPhysics(World world, float width, float height, Vector2 position)
        {
            _body = BodyFactory.CreateRectangle(world,
                                                ConvertUnits.ToSimUnits(width), ConvertUnits.ToSimUnits(height),
                                                DefaultVar.fObjectDensity, ConvertUnits.ToSimUnits(position));

            _body.BodyType = BodyType.Dynamic;

            _body.Restitution = DefaultVar.fObjectRestitution;
            _body.Friction = DefaultVar.fObjectFriction;

            _mover = new CMover(world, position, height, width);
        }

        private CMover _mover;

        private Body _body;  
    }

    public class CMover
    {
        public CMover(World world, Vector2 position, float height, float width)
        {
            _body = new Body(world);
            _body.BodyType = BodyType.Dynamic;
            _body.Position = position;
        }

        private Body _body;
    }
}
